package com.aistar.mapper;

import com.aistar.model.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName: EmployeeMapper
 * @author: LiuWenXiu
 * @date: 2021/9/26 21:05
 * @Description: TODO...本类用来演示:
 */
public interface EmployeeMapper {

    /**
     * 根据求职者id获取求职者姓名
     *
     * @param id 求职者id
     * @return
     */
    @Select("select name from employee where id = #{id}")
    String findNameById(Integer id);

    @Select("select * from employee where user_id = #{userId}")
    Employee findNameByUserId(Integer userId);

    @Select("select * from employee where id = #{id}")
    Employee findById(Integer id);

    //查询所有的求职者
    @Select("select * from employee")
    List<Employee> findAll();

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into employee(name,avatar_img,status,user_id) values(#{name},#{avatarImg},#{status},#{userId})")
    Integer insertEmployee(Employee employee);

    @Delete("delete from employee where user_id=#{userId}")
    Integer deleteByUserId(Integer userId);
}
